Section 3.6.8.8.2
Repeat Warp

The repeat warp causes a section of the pattern to be repeated over and over. It takes a slice out of the pattern and makes multiple copies of it side-by-side. The warp has many uses but was originally designed to make it easy to model wood veneer textures. Veneer is made by taking very thin slices from a log and placing them side-by-side on some other backing material. You see side-by-side nearly identical ring patterns but each will be a slice perhaps 1/32th of an inch deeper.

The syntax for a repeat warp is

warp { repeat VECTOR offset VECTOR flip VECTOR }

The repeat vector specifies the direction in which the pattern repeats and the width of the repeated area. This vector must lie entirely along an axis. In other words, two of its three components must be 0. For example:

pigment { wood warp {repeat 2*x} }

which means that from x=0 to x=2 you get whatever the pattern usually is. But from x=2 to x=4 you get the same thing exactly shifted 2 units over in the x direction. To evaluate it you simply take the X-coordinate modulo 2. Unfortunately you get exact duplicates which isn't very realistic. The optional offset vector tells how much to translate the pattern each time it repeats. For example

pigment { wood warp {repeat x*2 offset z*0.05} }

this means that we slice the first copy from x=0 to x=2 at z=0 but at x=2 to x=4 we offset to z=0.05. In the 4 to 6 interval we slice at z=0.10. At the Nth copy we slice at z*N*0.05. Thus each copy is slightly different. There are no restrictions on the offset vector.

Finally the flip vector causes the pattern to be flipped or mirrored every other copy of the pattern. The first copy of the pattern in the positive direction from the axis is not flipped; the next farther is; the next is not, etc. The flip vector is a 3 component x,y,z vector but each component is treated as a boolean value that tells if you should or should not flip along a given axis. For example:

pigment { wood warp {repeat 2*x flip <1,1,0>} }

means that every other copy of the pattern will be mirrored about the X and Y axis but not the Z axis. A non-zero value means flip and zero means do not flip about that axis. The magnitude of the values in the flip vector doesn't matter.


Section 3.6.8.8.3
Turbulence Warp

The POV-Ray language contains an ambiguity and limitation on the way you specify turbulence and transformations such as translate, rotate, scale and matrix transforms. Usually the turbulence is done first. Then ALL translate, rotate, scale and matrix operations are always done after turbulence regardless of the order in which you specify them. For example this

pigment { wood scale .5 turbulence .2 }

works exactly the same as

pigment { wood turbulence .2 scale .5 }

The turbulence is always first. A better example of this limitation is with uneven turbulence and rotations.

pigment { wood turbulence 0.5*y rotate z*60 } // as compared to pigment { wood rotate z*60 turbulence 0.5*y }

The results will be the same either way even though you'd think it should look different.

We cannot change this basic behavior in POV-Ray now because lots of scenes would potentially render differently if suddenly the order transformation vs turbulence suddenly mattered when in the past, it didn't.

However, by specifying our turbulence inside warp statement you tell POV-Ray that the order in which turbulence, transformations and other warps are applied is significant. Here's an example of a turbulence warp.

warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }

The significance is that this

pigment { wood translate <1,2,3> rotate x*45 scale 2 warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 } }

produces different results than this...

pigment { wood warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 } translate <1,2,3> rotate x*45 scale 2 }

You may specify turbulence without using a warp statement. However you cannot control the order in which they are evaluated unless you put them in a warp.

The evaluation rules are as follows:

1) First any turbulence not inside a warp statement is applied regardless of the order in which it appears relative to warps or transformations.
2) Next each warp statement, translate, rotate, scale or matrix one-by-one, is applied in the order the user specifies. If you want turbulence done in a specific order, you simply specify it inside a warp in the proper place.

Section 3.6.8.9
Bitmap modifiers

A bitmap modifier is a modifier used inside an "image_map" , "bump_map" or "material_map" to specify how the 2-D bitmap is to be applied to the 3-D surface. Several bitmap modifiers apply to specific kinds of maps and they are covered in the appropriate sections. The bitmap modifiers discussed in the following sections are applicable to all three types of bitmaps.

Section 3.6.8.9.1
The once Option

Normally there are an infinite number of repeating image_maps, bump_maps, or material_maps created over every unit square of the X-Y plane like tiles. By adding the keyword once after a file name, you can eliminate all other copies of the map except the one at (0,0) to (1,1). In image_maps, areas outside this unit square are treated as fully transparent. In bump_maps, areas outside this unit square are left flat with no normal modification. In material_maps, areas outside this unit square are textured with the first texture of the texture list.

For example:

image_map { gif "mypic.gif" once }

Section 3.6.8.9.2
The "map_type" Option

The default projection of the bump onto the X-Y plane is called a planar map type . This option may be changed by adding the map_type keyword followed by a number specifying the way to wrap the bump around the object.

A map_type 0 gives the default planar mapping already described.

A map_type 1 is a spherical mapping. It assumes that the object is a sphere of any size sitting at the origin. The Y axis is the north/south pole of the spherical mapping. The top and bottom edges of the bitmap just touch the pole regardless of any scaling. The left edge of the bitmap begins at the positive X axis and wraps the pattern around the sphere from "west" to "east" in a -Y rotation. The pattern covers the sphere exactly once. The once keyword has no meaning for this type.

With map_type 2 you get a cylindrical mapping. It assumes that a cylinder of any diameter lies along the Y axis. The bump pattern wraps around the cylinder just like the spherical map but remains 1 unit tall from y=0 to y=1. This band of the pattern is repeated at all heights unless the once keyword is applied.

Finally map_type 5 is a torus or donut shaped mapping. It assumes that a torus of major radius 1 sits at the origin in the X-Z plane. The pattern is wrapped around similar to spherical or cylindrical maps. However the top and bottom edges of the map wrap over and under the torus where they meet each other on the inner rim.

Types 3 and 4 are still under development.

For example:

sphere{<0,0,0>,1 pigment{ image_map { gif "world.gif" map_type 1 } } }

Section 3.6.8.9.3
The interpolate Option

Adding the interpolate keyword can smooth the jagged look of a bitmap. When POV-Ray asks an image_map color or a bump amount for a bump map, it often asks for a point that is not directly on top of one pixel, but sort of between several different colored pixels. Interpolations returns an "in-between" value so that the steps between the pixels in the map will look smoother.

Although interpolate is legal in material_maps, the color index is interpolated before the texture is chosen. It does not interpolate the final color as you might hope it would. In general, interpolation of material_map serves no useful purpose but this may be fixed in future versions.

There are currently two types of interpolation:

  Normalized Distance -- interpolate 4
  Bilinear            -- interpolate 2

For example:

image_map { gif "mypic.gif" interpolate 2 }

Default is no interpolation. Normalized distance is the slightly faster of the two, bilinear does a better job of picking the between color. Normally, bilinear is used.

If your map looks jaggy, try using interpolation instead of going to a higher resolution image. The results can be very good.


Section 3.7
Atmospheric Effects

Atmospheric effects are a loosely-knit group of features that affect the background and/or the atmosphere enclosing the scene. POV-Ray includes the ability to render a number of atmospheric effects, such as fog, haze, mist, rainbows, and skies.

Section 3.7.1
Atmosphere

Computer generated images normally assume a vacuum space that does not allow the rendering of natural phenomena like smoke, light beams, etc. A very simple approach to add fog to a scene is explained in section "Fog" . This kind of fog does not interact with any light sources though. It will not show light beams or other effects and is therefore not very realistic.

The atmosphere effect overcomes some of the fog's limitations by calculating the interaction between light and the particles in the atmosphere using volume sampling. Thus shaft of light beams will become visible and objects will cast shadows "onto" the smoke or fog.

The syntax of the atmosphere is:

atmosphere { type TYPE distance DISTANCE [ scattering SCATTERING ] [ eccentricity ECCENTRICITY ] [ samples SAMPLES ] [ jitter JITTER ] [ aa_threshold AA_THRESHOLD ] [ aa_level AA_LEVEL ] [ color <COLOUR> ] }

The "type" keyword determines the type of scattering model to be used. There are five different phase functions representing the different models: isotropic, Rayleigh, Mie (haze and murky atmosphere) and Henyey-Greenstein.

Isotropic scattering is the simplest form of scattering because it is independent of direction. The amount of light scattered by particles in the atmosphere does not depend on the angle between the viewing direction and the incoming light.

Rayleigh scattering models the scattering for extremely small particles such as molecules of the air. The amount of scattered light depends on the incident light angle. It is largest when the incident light is parallel or anti-parallel to the viewing direction and smallest when the incident light is perpendicular to the viewing direction. You should note that the Rayleigh model used here does not take the dependency of scattering on the wavelength into account.

The Mie scattering is used for relatively small particles such as miniscule water droplets of fog, cloud particles, and particles responsible for the polluted sky. In this model the scattering is extremely directional in the forward direction i.e. the amount of scattered light is largest when the incident light is anti-parallel to the viewing direction (the light goes directly to the viewer). It is smallest when the incident light is parallel to the viewing direction. The haze and murky atmosphere models differ in their scattering characteristics. The murky model is much more directional than the haze model.

The Henyey-Greenstein scattering is based on an analytical function and can be used to model a large variety of different scattering types. The function models an ellipse with a given eccentricity e. This eccentricity is given by the optional keyword "eccentricity". A value of zero defines isotropic scattering while positive values lead to scattering in the direction of the light and negative values lead to scattering in the opposite direction of the light. Larger values of e (or smaller values in the negative case) increase the directional property of the scattering.

The easiest way to use the different scattering types will be to declare some constants and use those in your atmosphere definition:

#declare ISOTROPIC_SCATTERING = 1 #declare MIE_HAZY_SCATTERING = 2 #declare MIE_MURKY_SCATTERING = 3 #declare RAYLEIGH_SCATTERING = 4 #declare HENYEY_GREENSTEIN_SCATTERING = 5

The "distance" keyword is used to determine the density of the particles in the atmosphere. This density is constant for the whole atmosphere. The distance parameter works in the same way as the fog distance.

With the "scattering" keyword you can change the amount of scattering. This is useful to fit the intensity of the scattered light to your and your scene's needs.

Since the atmosphere is calculated by sampling along the viewing ray and looking for contributions from light sources, it is prone to aliasing (just like any sampling technique). There are four parameters to minimize the artifacts that may be visible: "samples", "jitter", "aa_level", and "aa_threshold".

The "samples" keyword determines how many samples are calculated in one interval along the viewing ray. The length of the interval is either the distance as given by the distance keyword or the length of the "lit" part of the viewing ray, whichever is smaller. This lit part is a section of the ray that is "most likely" lit by a light source. In the case of a spotlight it is the part of the ray that lies in the cone of light. In other cases it becomes more difficult. The only thing you should keep in mind is that the actual sampling interval length is variable but there will never be fewer than the specified samples in the specified distance.

One technique to reduce the visibility of sampling artifacts is to jitter the sample points, i.e. to add random noise to their location. This can be done with the "jitter" keyword.

Another technique is supersampling (an anti-aliasing method). This helps to avoid missing features by adding additional samples in places were high intensity changes occur (e.g. the edge of a shadow). The anti-aliasing is turned on by the "aa_level" keyword. If this is larger than zero supersampling will be used. The additional samples will be recursively placed between two samples with a high intensity change. The level to which subdivision takes places is specified by the "aa_level" keyword. Level one means one subdivision (one additional sample), level two means two subdivisions (up to three additional samples), etc.

The threshold for the intensity change is given by the "aa_threshold" keyword. If the intensity change is greater than this threshold anti-aliasing will be used for those two samples.

With spotlights you'll be able to create the best results because their cone of light will become visible. Pointlights can be used to create effects like street lights in fog. Fill-lights are not taken into account when calculating atmospheric effects. They can be used to increase the overall light level off the scene to make it look more realistic.


Section 3.7.2
Background

A background color can be specified if desired. Any ray that doesn't hit an object will be colored with this color. The default background is black. The syntax for background is:

background { colour <COLOUR> }

Section 3.7.3
Fog

Fog is defined by the following statement:

fog { fog_type FOG_TYPE distance DISTANCE colour <COLOUR> [ turbulence <TURBULENCE> ] [ turb_depth TURB_DEPTH ] [ omega OMEGA ] [ lambda LAMBDA ] [ octaves OCTAVES ] [ fog_offset FOG_OFFSET ] [ fog_alt FOG_ALT ] }

Currently there are two fog types, constant fog and ground fog. Constant fog has a constant density everywhere while ground fog thins out along the y-axis. The location of the maximum density is given by the "fog_offset" keyword and the height of the fog layer is specified by the "fog_alt" keyword. The ground fog fades to nothing along the y-axis from fog_offset to the distance fog_alt.

Two constants are defined for easy use of the fog types in the file "const.inc":

// FOG TYPE CONSTANTS #declare Constant_Fog = 1 #declare Ground_Fog = 2

The color of a pixel with an intersection depth d is calculated by

C_pixel = exp(-d/D) * C_object + (1-exp(-d/D)) * C_fog

where D is the fog distance. At depth 0 the final color is the object's color. If the intersection depth equals the fog distance the final color consists of 64% of the object's color and 36% of the fog's color.

The fog color that is given by the "color" keyword has three purposes. First it defines the color to be used in blending the fog and the background. Second it is used to specify a translucency threshold. By using a transmittance larger than zero one can make sure that at least that amount of light will be seen through the fog. With a transmittance of 0.3 you'll see at least 30% of the background. Third it can be used to make a filtering fog. With a filter value f larger than zero the amount of background light given by f will be multiplied with the fog color. A filter value of 0.7 will lead to a fog that filters 70% of the background light and leaves 30% unfiltered.

Fogs may be "layered". That is, you can apply as many layers of fog as you like. Generally this is most effective if each layer is a ground fog of different color, altitude, and with different turbulence values.

To use multiple layers of fogs, just add all of them to the scene.

You may optionally stir up the fog by adding turbulence. The turbulence keyword may be followed by a float or vector to specify an amount of turbulence to be used. The omega, lambda and octaves turbulence parameters may also be specified. See "turbulence" for details on all of these turbulence parameters.

Additionally the fog turbulence may be scaled along the direction of the viewing ray using the turb_depth amount. Typical values are from 0.0 to 1.0 or more. The default value is 0.5 but and float value may be used.


Next Section
Table Of Contents